Structure learning
The structure of a graphical models reveals the generative process of
the data at hand. For this reason, BNs are interpretable and intuitive.
Learning the structure from data is the most challenging yet insightful
step in a BN analysis. However, if the structure is already known, or
can be guessed, this can be pre-specified by an expert. In this way, BNs
represent a perfect hybrid of expert and data-driven learning.
Initialize structure
This section relies on expert/prior knowledge and enables the user to
upload a network graph as a .CSV file to initialize the bayesian
learning graph. The user can also add, remove or reverse the direction
of any arc, once the graph has been uploaded. (Only used in score-based
learning)

Figure S 15. Graph initialization settings
Learn Structure
In the absence of expert knowledge, independencies can be directly
learnt from the data itself. The computational learning of structure can
be done using a number of bayesian learning algorithms such as
- Score-based (Recommended):- Hill Climbing, Tabu
- Constraint-based:- Grow-Shrink, Incremental Association, Fast IAMB, Inter IAMB,PC
- Hybrid Learning:- Max-Min Hill Climbing, 2-phase Restricted Maximization
- Local Discovery:- Max-Min Parents and Children,Semi-Interleaved HITON-PC, ARACNE, Chow-Liu
Options used in structure learning include:-
- Parameter fitting algorithm:- Bayesian parameter estimation (recommended), maximum likelihood parameter estimation
- Network score:- Bayesian Information Criterion, Bayesian Dirichlet
Equivalent, modified Bayesian Dirichlet Equivalent,
log-likelihood,Akaike Information Criterion,Bayesian Dirichlet
Sparse,Locally Averaged Bayesian Dirichlet (Only used in score-based
learning)
- Imaginary sample size (Only used in score-based learning)
- Incorporate expert knowledge via blacklisting (explicitly restrict
edges in structure learning) and whitelisting (explicitly enforce edges
in structure learning) edges by uploading a .CSV file for the same
- Disabling data resampling in bootstrap learning. This is
particularly useful for data with low sample size. In this case, the
data remain same but the graph is re-initialized every time. This method
is only possible for score based algorithms as it requires random graph
initialization.
- Bootstrap iterations:- Bootstrapping means sampling the data with
replacement. This parameter specifies the number of bootstrap iterations
to run for bootstrapped structure learning.
- Bootstrap sample size:- Proportion of data to be used as sample for bootstrap learning.
- Edge strength:- Set a threshold value between 0 and 1 to remove
edges below specified strength from the final structure. Edge strength
can be interpreted as the probability of occurrence of an edge in
bootstrap learning.
- Edge direction:- Set a threshold value between 0 and 1 to remove
edges below specified direction confidence from the final structure.
Edge direction can be interpreted the confidence of direction of a
learned arc in bootstrap learning.
- Although not recommended, bootstrap based structure learning may be
by-passed via the “Direct Learning” option for learning the structure
without bootstraps. Please note that this is suitable only for quick
exploration and may give less robust structure.
Important Notes
The user does not have to do the bootstrap learning every time if
they wish to explore different thresholds for edge and direction
strength. This can be achieved by using the parameter tuning option.
The final learnt structure can be saved as a as a bnlearn object in .RData format through the save option.

Figure S16. Structure learning settings
Upload pre-learnt structure
A user returning to analysis should not need to repeat the above
steps. An already learnt and saved bayesian network structure can be
uploaded as an .RData file.
Options to upload both bootstrapped and direct structure and adjusting their parameters are available in the app.

Figure S17. Upload pre-learnt structure
Edit structure
wiseR allows expert checks at every step
and an expert can identify edges and directions that are not plausible
in the real world (e.g. smoking cannot influence natural gender,
but the reverse can happen). An expert can add/remove arcs, or reverse
the direction of the existing ones on the basis of plausibility.

Figure S18. Edit learned structure via adding, removing or reversing directions based upon expert knowledge and plausibility.
External Graph
wiseR allows user to work with an external
graph through the app. It is possible user may want to test out newer
graph learning algorithms which are not available through the app. This
ensures the user access to app features provided they have a edgelist of
the external graph in “from” and “to” structure saved as a “.csv”

Figure S19. Provision for uploading externally learned graph to work through the App.
Graph Neural Networks
With the current advances in Graph based machine learning, wiser
provides the standard GNN based structure learning method through the
app. The user is asked to provide the Python and Cuda environment path
with all requisit libraries such as:
- pytorch
- matplotlib
- networkx
- pandas
- scipy
- scikit-learn
The user can provide the no. of bootstraps for averaged structure learning. Please note, the user must ensure CUDA enabled system for functioning of GNN through the App.

Figure S20. GNN based structure learning through the App.
Validate structure
This section enables the analyst to validate the learnt structure using 10-fold cross-validation or hold-out testing.
The log-likelihood loss and network score outputs produced can then be used to judge the usability of the learned structure.

Figure S21. Validation of the learnt structure through cross-validation and hold-out testing.
Inference
After the parametrization of BN is complete, it can be queried to
derive inferences and reason about the data. The inference learning menu
enables the user to learn and explore conditional probability plots on
the learned structure. The user can set an event and multiple evidences
can be inserted as per the query. This crucial feature enables the user
to explore probability plots on event nodes in the network
conditionalized on chain of evidences, which is the essence of decision
making through bayesian networks.
Inferences can be learnt through two methods using wiseR
- Approximate Inference (Fast, Monte Carlo sampling of local
structure). This option is useful for large datasets where exact
inference is intractable. However, the sampling is implemented every
time, hence adding incrementally to computational overhead over time.
Also it yields slightly different results on each iteration. The app has
the feature to re-compute approximate inferences for a specified number
of times and to plot error bars in the inference.
- Exact inference (Fast for small networks, slow for large networks, one-time computation)
Assuming that the User is working with large datasets, approximate
inference is the default setting. This can be switched in the app. It is
observed that the inference plots produced using approximate inference
with error bars, is almost as accurate as exact inference, hence can
enable robust reasoning and decisions on large datasets where exact
inference is not possible.

Figure S26. Visualiation and tables available to be exported from the application.
Taking Decisions with the learnt network
Heads-up: This section relies upon JAGS installation on their system. JAGS can be downloaded from its official page.
As per our knowledge, there is no available open-source tool or a
package in R that integrates structure learning with decision making.
Influence diagrams have typically been defined by hand by experts. wiseR
integrates these two capabilities to help the analyst arrive at the
best (or next-best) policy for optimizing a payoff. For this purpose,
the use can create a payoff node based off the variable that they wish
to optimize (known as the utility node, e.g. Blood Pressure
optimization in the Intensive Care Unit). This brings up the table to
enter the utility of each state in the range of -1 to 1. For example, a
user may assign a negative utility to an abnormally low or high blood
pressure event (-1) and a positive (+1) utitilty to normal blood
pressure. Alternatively, if the user does not care as much about the
high blood pressure as they would care about low blood pressure
(e.g. shock in the ICU), they can assign a zero utility to the high
blood pressure event. After this the user sets the decision nodes that
are direct parents of the node their utility node. If the policy from
parents is expected to be obvious, they can go to grandparents or orders
higher, however the effects may diminish. Finally the user runs the
Monte-carlo simulation that displays the best policy along with the
payoffs in a sorted table. This leap from making subjective inferences
to policy advice makes wiseR a white-box appproach to actionable, transparent and interpretable machine learning.